/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2005                    */
/* Created on:     10/06/2012 0:51:10                           */
/*==============================================================*/


if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('BLOCK') and o.name = 'FK_BLOCK_FK_CU_BL_CUSTOMER')
alter table BLOCK
   drop constraint FK_BLOCK_FK_CU_BL_CUSTOMER
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('BLOCK') and o.name = 'FK_BLOCK_FK_GL_BL_GEOLOC')
alter table BLOCK
   drop constraint FK_BLOCK_FK_GL_BL_GEOLOC
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('CABLE') and o.name = 'FK_CABLE_FK_CA_CB_CABLEAWG')
alter table CABLE
   drop constraint FK_CABLE_FK_CA_CB_CABLEAWG
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('CABLE') and o.name = 'FK_CABLE_FK_CL_CB_CABLELEV')
alter table CABLE
   drop constraint FK_CABLE_FK_CL_CB_CABLELEV
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('CABLE') and o.name = 'FK_CABLE_FK_CM_CB_CABLEMOD')
alter table CABLE
   drop constraint FK_CABLE_FK_CM_CB_CABLEMOD
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('CABLE') and o.name = 'FK_CABLE_FK_CR_CB_CABLEARM')
alter table CABLE
   drop constraint FK_CABLE_FK_CR_CB_CABLEARM
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('CONTINFO') and o.name = 'FK_CONTINFO_FK_MN_CI_MANUFACT')
alter table CONTINFO
   drop constraint FK_CONTINFO_FK_MN_CI_MANUFACT
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('CONTINFO') and o.name = 'FK_CONTINFO_FK_ST_CI_SYSTYPE')
alter table CONTINFO
   drop constraint FK_CONTINFO_FK_ST_CI_SYSTYPE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('COUNTRY') and o.name = 'FK_COUNTRY_FK_GM_CN_GEOMAR')
alter table COUNTRY
   drop constraint FK_COUNTRY_FK_GM_CN_GEOMAR
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('ELECTCONN') and o.name = 'FK_ELECTCON_FK_EM_EC_ELECTMAN')
alter table ELECTCONN
   drop constraint FK_ELECTCON_FK_EM_EC_ELECTMAN
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('FAILANA') and o.name = 'FK_FAILANA_FK_CC_FA_CONCEN')
alter table FAILANA
   drop constraint FK_FAILANA_FK_CC_FA_CONCEN
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('FAILANA') and o.name = 'FK_FAILANA_FK_FC_FA_FAILCOM')
alter table FAILANA
   drop constraint FK_FAILANA_FK_FC_FA_FAILCOM
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('FAILANA') and o.name = 'FK_FAILANA_FK_FS_FA_FAILSUB')
alter table FAILANA
   drop constraint FK_FAILANA_FK_FS_FA_FAILSUB
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('FAILANA') and o.name = 'FK_FAILANA_FK_GC_FA_GENCEN')
alter table FAILANA
   drop constraint FK_FAILANA_FK_GC_FA_GENCEN
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('FAILANA') and o.name = 'FK_FAILANA_FK_PC_FA_PULLCAUS')
alter table FAILANA
   drop constraint FK_FAILANA_FK_PC_FA_PULLCAUS
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('FAILANA') and o.name = 'FK_FAILANA_FK_SF_FA_SPEFAIL')
alter table FAILANA
   drop constraint FK_FAILANA_FK_SF_FA_SPEFAIL
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('FIELD') and o.name = 'FK_FIELD_FK_BL_FL_BLOCK')
alter table FIELD
   drop constraint FK_FIELD_FK_BL_FL_BLOCK
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('GEOLOC') and o.name = 'FK_GEOLOC_FK_CN_GL_COUNTRY')
alter table GEOLOC
   drop constraint FK_GEOLOC_FK_CN_GL_COUNTRY
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('INTGAS') and o.name = 'FK_INTGAS_FK_IO_IN_INTGASOP')
alter table INTGAS
   drop constraint FK_INTGAS_FK_IO_IN_INTGASOP
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('INTGAS') and o.name = 'FK_INTGAS_FK_IT_IN_INTGASTY')
alter table INTGAS
   drop constraint FK_INTGAS_FK_IT_IN_INTGASTY
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('INTGAS') and o.name = 'FK_INTGAS_FK_MT_IN_METAL')
alter table INTGAS
   drop constraint FK_INTGAS_FK_MT_IN_METAL
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('INTGASTYPE') and o.name = 'FK_INTGASTY_FK_IS_IT_INTGASSE')
alter table INTGASTYPE
   drop constraint FK_INTGASTY_FK_IS_IT_INTGASSE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('MLE') and o.name = 'FK_MLE_FK_MLA_ML_MLEARMOR')
alter table MLE
   drop constraint FK_MLE_FK_MLA_ML_MLEARMOR
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('MLE') and o.name = 'FK_MLE_FK_MLM_ML_MLEMODEL')
alter table MLE
   drop constraint FK_MLE_FK_MLM_ML_MLEMODEL
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('MLE') and o.name = 'FK_MLE_FK_MLS_ML_MLESERIE')
alter table MLE
   drop constraint FK_MLE_FK_MLS_ML_MLESERIE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('MLE') and o.name = 'FK_MLE_FK_MLT_ML_MLETYPE')
alter table MLE
   drop constraint FK_MLE_FK_MLT_ML_MLETYPE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('MOTOR') and o.name = 'FK_MOTOR_FK_ML_MO_MOTORLEV')
alter table MOTOR
   drop constraint FK_MOTOR_FK_ML_MO_MOTORLEV
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('MOTOR') and o.name = 'FK_MOTOR_FK_MM_MO_MOTORMOD')
alter table MOTOR
   drop constraint FK_MOTOR_FK_MM_MO_MOTORMOD
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('MOTOR') and o.name = 'FK_MOTOR_FK_MS_MO_MOTEORSE')
alter table MOTOR
   drop constraint FK_MOTOR_FK_MS_MO_MOTEORSE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('MOTOR') and o.name = 'FK_MOTOR_FK_MT_MO_METAL')
alter table MOTOR
   drop constraint FK_MOTOR_FK_MT_MO_METAL
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('MOTOR') and o.name = 'FK_MOTOR_FK_MY_MO_MOTORTYP')
alter table MOTOR
   drop constraint FK_MOTOR_FK_MY_MO_MOTORTYP
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('OPERINFO') and o.name = 'FK_OPERINFO_FK_CE_OI_CURRESPS')
alter table OPERINFO
   drop constraint FK_OPERINFO_FK_CE_OI_CURRESPS
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('OPERINFO') and o.name = 'FK_OPERINFO_FK_WI_OI_WELLINFO')
alter table OPERINFO
   drop constraint FK_OPERINFO_FK_WI_OI_WELLINFO
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('OPERINFO') and o.name = 'FK_OPERINFO_FK_WS_OI_WELLSTAT')
alter table OPERINFO
   drop constraint FK_OPERINFO_FK_WS_OI_WELLSTAT
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PULLCAUSE') and o.name = 'FK_PULLCAUS_FK_AC_PC_AFFCOM')
alter table PULLCAUSE
   drop constraint FK_PULLCAUS_FK_AC_PC_AFFCOM
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PULLCAUSE') and o.name = 'FK_PULLCAUS_FK_GP_PC_GENPULLC')
alter table PULLCAUSE
   drop constraint FK_PULLCAUS_FK_GP_PC_GENPULLC
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PULLCAUSE') and o.name = 'FK_PULLCAUS_FK_PR_PC_PULLREA')
alter table PULLCAUSE
   drop constraint FK_PULLCAUS_FK_PR_PC_PULLREA
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PULLCAUSE') and o.name = 'FK_PULLCAUS_FK_RL_PC_RUNLIFED')
alter table PULLCAUSE
   drop constraint FK_PULLCAUS_FK_RL_PC_RUNLIFED
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PULLCAUSE') and o.name = 'FK_PULLCAUS_FK_SP_PC_SPEPULLC')
alter table PULLCAUSE
   drop constraint FK_PULLCAUS_FK_SP_PC_SPEPULLC
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PUMP') and o.name = 'FK_PUMP_FK_MT_PU_METAL')
alter table PUMP
   drop constraint FK_PUMP_FK_MT_PU_METAL
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PUMP') and o.name = 'FK_PUMP_FK_PL_PU_PUMPLEVE')
alter table PUMP
   drop constraint FK_PUMP_FK_PL_PU_PUMPLEVE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PUMP') and o.name = 'FK_PUMP_FK_PM_PU_PUMPMODE')
alter table PUMP
   drop constraint FK_PUMP_FK_PM_PU_PUMPMODE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PUMP') and o.name = 'FK_PUMP_FK_PS_PU_PUMPSERI')
alter table PUMP
   drop constraint FK_PUMP_FK_PS_PU_PUMPSERI
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('PUMPMODEL') and o.name = 'FK_PUMPMODE_FK_PT_PM_PUMPTYPE')
alter table PUMPMODEL
   drop constraint FK_PUMPMODE_FK_PT_PM_PUMPTYPE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('RUNLIFEDAT') and o.name = 'FK_RUNLIFED_FK_EQ_RL_EQUIPMEN')
alter table RUNLIFEDAT
   drop constraint FK_RUNLIFED_FK_EQ_RL_EQUIPMEN
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('RUNLIFEDAT') and o.name = 'FK_RUNLIFED_FK_OI_RL_OPERINFO')
alter table RUNLIFEDAT
   drop constraint FK_RUNLIFED_FK_OI_RL_OPERINFO
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SEAL') and o.name = 'FK_SEAL_FK_MT_SE_METAL')
alter table SEAL
   drop constraint FK_SEAL_FK_MT_SE_METAL
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SEAL') and o.name = 'FK_SEAL_FK_SH_SE_SEALSHAF')
alter table SEAL
   drop constraint FK_SEAL_FK_SH_SE_SEALSHAF
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SEAL') and o.name = 'FK_SEAL_FK_SL_SE_SEALLEVE')
alter table SEAL
   drop constraint FK_SEAL_FK_SL_SE_SEALLEVE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SEAL') and o.name = 'FK_SEAL_FK_SM_SE_SEALMODE')
alter table SEAL
   drop constraint FK_SEAL_FK_SM_SE_SEALMODE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SEAL') and o.name = 'FK_SEAL_FK_SS_SE_SEALSERI')
alter table SEAL
   drop constraint FK_SEAL_FK_SS_SE_SEALSERI
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SENSOR') and o.name = 'FK_SENSOR_FK_MT_SN_METAL')
alter table SENSOR
   drop constraint FK_SENSOR_FK_MT_SN_METAL
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SENSOR') and o.name = 'FK_SENSOR_FK_SNM_SN_SENSORMO')
alter table SENSOR
   drop constraint FK_SENSOR_FK_SNM_SN_SENSORMO
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SENSOR') and o.name = 'FK_SENSOR_FK_SNS_SN_SENSORSE')
alter table SENSOR
   drop constraint FK_SENSOR_FK_SNS_SN_SENSORSE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SENSOR') and o.name = 'FK_SENSOR_FK_SNT_SN_SENSORTY')
alter table SENSOR
   drop constraint FK_SENSOR_FK_SNT_SN_SENSORTY
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('WELL') and o.name = 'FK_WELL_FK_FL_WL_FIELD')
alter table WELL
   drop constraint FK_WELL_FK_FL_WL_FIELD
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('WELL') and o.name = 'FK_WELL_FK_PZ_WL_PRODZONE')
alter table WELL
   drop constraint FK_WELL_FK_PZ_WL_PRODZONE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('WELL') and o.name = 'FK_WELL_FK_WT_WL_WELLTYPE')
alter table WELL
   drop constraint FK_WELL_FK_WT_WL_WELLTYPE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('WELLINFO') and o.name = 'FK_WELLINFO_FK_CI_WI_CONTINFO')
alter table WELLINFO
   drop constraint FK_WELLINFO_FK_CI_WI_CONTINFO
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('XFRMVSD') and o.name = 'FK_XFRMVSD_FK_XM_XV_XVMAN')
alter table XFRMVSD
   drop constraint FK_XFRMVSD_FK_XM_XV_XVMAN
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('XFRMVSD') and o.name = 'FK_XFRMVSD_FK_XP_XV_XVPULSES')
alter table XFRMVSD
   drop constraint FK_XFRMVSD_FK_XP_XV_XVPULSES
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('XFRMVSD') and o.name = 'FK_XFRMVSD_FK_XT_XV_XVTYPE')
alter table XFRMVSD
   drop constraint FK_XFRMVSD_FK_XT_XV_XVTYPE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('AFFCOM')
            and   type = 'U')
   drop table AFFCOM
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('BLOCK')
            and   name  = 'FK_CU_BL_FK'
            and   indid > 0
            and   indid < 255)
   drop index BLOCK.FK_CU_BL_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('BLOCK')
            and   name  = 'FK_GL_BL_FK'
            and   indid > 0
            and   indid < 255)
   drop index BLOCK.FK_GL_BL_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('BLOCK')
            and   type = 'U')
   drop table BLOCK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('CABLE')
            and   name  = 'FK_CR_CB_FK'
            and   indid > 0
            and   indid < 255)
   drop index CABLE.FK_CR_CB_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('CABLE')
            and   name  = 'FK_CL_CB_FK'
            and   indid > 0
            and   indid < 255)
   drop index CABLE.FK_CL_CB_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('CABLE')
            and   name  = 'FK_CA_CB_FK'
            and   indid > 0
            and   indid < 255)
   drop index CABLE.FK_CA_CB_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('CABLE')
            and   name  = 'FK_CM_CB_FK'
            and   indid > 0
            and   indid < 255)
   drop index CABLE.FK_CM_CB_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CABLE')
            and   type = 'U')
   drop table CABLE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CABLEARMOR')
            and   type = 'U')
   drop table CABLEARMOR
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CABLEAWG')
            and   type = 'U')
   drop table CABLEAWG
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CABLELEVEL')
            and   type = 'U')
   drop table CABLELEVEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CABLEMODEL')
            and   type = 'U')
   drop table CABLEMODEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CONCEN')
            and   type = 'U')
   drop table CONCEN
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('CONTINFO')
            and   name  = 'FK_MN_CI_FK'
            and   indid > 0
            and   indid < 255)
   drop index CONTINFO.FK_MN_CI_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('CONTINFO')
            and   name  = 'FK_ST_CI_FK'
            and   indid > 0
            and   indid < 255)
   drop index CONTINFO.FK_ST_CI_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CONTINFO')
            and   type = 'U')
   drop table CONTINFO
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('COUNTRY')
            and   name  = 'FK_GM_CN_FK'
            and   indid > 0
            and   indid < 255)
   drop index COUNTRY.FK_GM_CN_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('COUNTRY')
            and   type = 'U')
   drop table COUNTRY
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CURRESPSTAT')
            and   type = 'U')
   drop table CURRESPSTAT
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CUSTOMER')
            and   type = 'U')
   drop table CUSTOMER
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('ELECTCONN')
            and   name  = 'FK_EM_EC_FK'
            and   indid > 0
            and   indid < 255)
   drop index ELECTCONN.FK_EM_EC_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('ELECTCONN')
            and   type = 'U')
   drop table ELECTCONN
go

if exists (select 1
            from  sysobjects
           where  id = object_id('ELECTMAN')
            and   type = 'U')
   drop table ELECTMAN
go

if exists (select 1
            from  sysobjects
           where  id = object_id('EQUIPMENT')
            and   type = 'U')
   drop table EQUIPMENT
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('FAILANA')
            and   name  = 'FK_PC_FA_FK'
            and   indid > 0
            and   indid < 255)
   drop index FAILANA.FK_PC_FA_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('FAILANA')
            and   name  = 'FK_CC_FA_FK'
            and   indid > 0
            and   indid < 255)
   drop index FAILANA.FK_CC_FA_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('FAILANA')
            and   name  = 'FK_GC_FA_FK'
            and   indid > 0
            and   indid < 255)
   drop index FAILANA.FK_GC_FA_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('FAILANA')
            and   name  = 'FK_SF_FA_FK'
            and   indid > 0
            and   indid < 255)
   drop index FAILANA.FK_SF_FA_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('FAILANA')
            and   name  = 'FK_FS_FA_FK'
            and   indid > 0
            and   indid < 255)
   drop index FAILANA.FK_FS_FA_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('FAILANA')
            and   name  = 'FK_FC_FA_FK'
            and   indid > 0
            and   indid < 255)
   drop index FAILANA.FK_FC_FA_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('FAILANA')
            and   type = 'U')
   drop table FAILANA
go

if exists (select 1
            from  sysobjects
           where  id = object_id('FAILCOM')
            and   type = 'U')
   drop table FAILCOM
go

if exists (select 1
            from  sysobjects
           where  id = object_id('FAILSUB')
            and   type = 'U')
   drop table FAILSUB
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('FIELD')
            and   name  = 'FK_BL_FL_FK'
            and   indid > 0
            and   indid < 255)
   drop index FIELD.FK_BL_FL_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('FIELD')
            and   type = 'U')
   drop table FIELD
go

if exists (select 1
            from  sysobjects
           where  id = object_id('GENCEN')
            and   type = 'U')
   drop table GENCEN
go

if exists (select 1
            from  sysobjects
           where  id = object_id('GENPULLCAU')
            and   type = 'U')
   drop table GENPULLCAU
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('GEOLOC')
            and   name  = 'FK_CN_GL_FK'
            and   indid > 0
            and   indid < 255)
   drop index GEOLOC.FK_CN_GL_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('GEOLOC')
            and   type = 'U')
   drop table GEOLOC
go

if exists (select 1
            from  sysobjects
           where  id = object_id('GEOMAR')
            and   type = 'U')
   drop table GEOMAR
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('INTGAS')
            and   name  = 'FK_MT_IN_FK'
            and   indid > 0
            and   indid < 255)
   drop index INTGAS.FK_MT_IN_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('INTGAS')
            and   name  = 'FK_IO_IN_FK'
            and   indid > 0
            and   indid < 255)
   drop index INTGAS.FK_IO_IN_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('INTGAS')
            and   name  = 'FK_IT_IN_FK'
            and   indid > 0
            and   indid < 255)
   drop index INTGAS.FK_IT_IN_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('INTGAS')
            and   type = 'U')
   drop table INTGAS
go

if exists (select 1
            from  sysobjects
           where  id = object_id('INTGASOP')
            and   type = 'U')
   drop table INTGASOP
go

if exists (select 1
            from  sysobjects
           where  id = object_id('INTGASSERIE')
            and   type = 'U')
   drop table INTGASSERIE
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('INTGASTYPE')
            and   name  = 'FK_IS_IT_FK'
            and   indid > 0
            and   indid < 255)
   drop index INTGASTYPE.FK_IS_IT_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('INTGASTYPE')
            and   type = 'U')
   drop table INTGASTYPE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MANUFACT')
            and   type = 'U')
   drop table MANUFACT
go

if exists (select 1
            from  sysobjects
           where  id = object_id('METAL')
            and   type = 'U')
   drop table METAL
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('MLE')
            and   name  = 'FK_MLA_ML_FK'
            and   indid > 0
            and   indid < 255)
   drop index MLE.FK_MLA_ML_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('MLE')
            and   name  = 'FK_MLT_ML_FK'
            and   indid > 0
            and   indid < 255)
   drop index MLE.FK_MLT_ML_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('MLE')
            and   name  = 'FK_MLM_ML_FK'
            and   indid > 0
            and   indid < 255)
   drop index MLE.FK_MLM_ML_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('MLE')
            and   name  = 'FK_MLS_ML_FK'
            and   indid > 0
            and   indid < 255)
   drop index MLE.FK_MLS_ML_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MLE')
            and   type = 'U')
   drop table MLE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MLEARMOR')
            and   type = 'U')
   drop table MLEARMOR
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MLEMODEL')
            and   type = 'U')
   drop table MLEMODEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MLESERIE')
            and   type = 'U')
   drop table MLESERIE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MLETYPE')
            and   type = 'U')
   drop table MLETYPE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MOTEORSERIE')
            and   type = 'U')
   drop table MOTEORSERIE
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('MOTOR')
            and   name  = 'FK_MT_MO_FK'
            and   indid > 0
            and   indid < 255)
   drop index MOTOR.FK_MT_MO_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('MOTOR')
            and   name  = 'FK_ML_MO_FK'
            and   indid > 0
            and   indid < 255)
   drop index MOTOR.FK_ML_MO_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('MOTOR')
            and   name  = 'FK_MY_MO_FK'
            and   indid > 0
            and   indid < 255)
   drop index MOTOR.FK_MY_MO_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('MOTOR')
            and   name  = 'FK_MM_MO_FK'
            and   indid > 0
            and   indid < 255)
   drop index MOTOR.FK_MM_MO_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('MOTOR')
            and   name  = 'FK_MS_MO_FK'
            and   indid > 0
            and   indid < 255)
   drop index MOTOR.FK_MS_MO_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MOTOR')
            and   type = 'U')
   drop table MOTOR
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MOTORLEVEL')
            and   type = 'U')
   drop table MOTORLEVEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MOTORMODEL')
            and   type = 'U')
   drop table MOTORMODEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('MOTORTYPE')
            and   type = 'U')
   drop table MOTORTYPE
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('OPERINFO')
            and   name  = 'FK_WI_OI_FK'
            and   indid > 0
            and   indid < 255)
   drop index OPERINFO.FK_WI_OI_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('OPERINFO')
            and   name  = 'FK_CE_OI_FK'
            and   indid > 0
            and   indid < 255)
   drop index OPERINFO.FK_CE_OI_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('OPERINFO')
            and   name  = 'FK_WS_OI_FK'
            and   indid > 0
            and   indid < 255)
   drop index OPERINFO.FK_WS_OI_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('OPERINFO')
            and   type = 'U')
   drop table OPERINFO
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PRODZONE')
            and   type = 'U')
   drop table PRODZONE
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PULLCAUSE')
            and   name  = 'FK_RL_PC_FK'
            and   indid > 0
            and   indid < 255)
   drop index PULLCAUSE.FK_RL_PC_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PULLCAUSE')
            and   name  = 'FK_AC_PC_FK'
            and   indid > 0
            and   indid < 255)
   drop index PULLCAUSE.FK_AC_PC_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PULLCAUSE')
            and   name  = 'FK_SP_PC_FK'
            and   indid > 0
            and   indid < 255)
   drop index PULLCAUSE.FK_SP_PC_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PULLCAUSE')
            and   name  = 'FK_GP_PC_FK'
            and   indid > 0
            and   indid < 255)
   drop index PULLCAUSE.FK_GP_PC_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PULLCAUSE')
            and   name  = 'FK_PR_PC_FK'
            and   indid > 0
            and   indid < 255)
   drop index PULLCAUSE.FK_PR_PC_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PULLCAUSE')
            and   type = 'U')
   drop table PULLCAUSE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PULLREA')
            and   type = 'U')
   drop table PULLREA
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PUMP')
            and   name  = 'FK_MT_PU_FK'
            and   indid > 0
            and   indid < 255)
   drop index PUMP.FK_MT_PU_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PUMP')
            and   name  = 'FK_PL_PU_FK'
            and   indid > 0
            and   indid < 255)
   drop index PUMP.FK_PL_PU_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PUMP')
            and   name  = 'FK_PS_PU_FK'
            and   indid > 0
            and   indid < 255)
   drop index PUMP.FK_PS_PU_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PUMP')
            and   name  = 'FK_PM_PU_FK'
            and   indid > 0
            and   indid < 255)
   drop index PUMP.FK_PM_PU_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PUMP')
            and   type = 'U')
   drop table PUMP
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PUMPLEVEL')
            and   type = 'U')
   drop table PUMPLEVEL
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('PUMPMODEL')
            and   name  = 'FK_PT_PM_FK'
            and   indid > 0
            and   indid < 255)
   drop index PUMPMODEL.FK_PT_PM_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PUMPMODEL')
            and   type = 'U')
   drop table PUMPMODEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PUMPSERIE')
            and   type = 'U')
   drop table PUMPSERIE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PUMPTYPE')
            and   type = 'U')
   drop table PUMPTYPE
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('RUNLIFEDAT')
            and   name  = 'FK_EQ_RL_FK'
            and   indid > 0
            and   indid < 255)
   drop index RUNLIFEDAT.FK_EQ_RL_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('RUNLIFEDAT')
            and   name  = 'FK_OI_RL_FK'
            and   indid > 0
            and   indid < 255)
   drop index RUNLIFEDAT.FK_OI_RL_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('RUNLIFEDAT')
            and   type = 'U')
   drop table RUNLIFEDAT
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('SEAL')
            and   name  = 'FK_MT_SE_FK'
            and   indid > 0
            and   indid < 255)
   drop index SEAL.FK_MT_SE_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('SEAL')
            and   name  = 'FK_SL_SE_FK'
            and   indid > 0
            and   indid < 255)
   drop index SEAL.FK_SL_SE_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('SEAL')
            and   name  = 'FK_SH_SE_FK'
            and   indid > 0
            and   indid < 255)
   drop index SEAL.FK_SH_SE_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('SEAL')
            and   name  = 'FK_SM_SE_FK'
            and   indid > 0
            and   indid < 255)
   drop index SEAL.FK_SM_SE_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('SEAL')
            and   name  = 'FK_SS_SE_FK'
            and   indid > 0
            and   indid < 255)
   drop index SEAL.FK_SS_SE_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SEAL')
            and   type = 'U')
   drop table SEAL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SEALLEVEL')
            and   type = 'U')
   drop table SEALLEVEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SEALMODEL')
            and   type = 'U')
   drop table SEALMODEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SEALSERIE')
            and   type = 'U')
   drop table SEALSERIE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SEALSHAFT')
            and   type = 'U')
   drop table SEALSHAFT
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('SENSOR')
            and   name  = 'FK_MT_SN_FK'
            and   indid > 0
            and   indid < 255)
   drop index SENSOR.FK_MT_SN_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('SENSOR')
            and   name  = 'FK_SNT_SN_FK'
            and   indid > 0
            and   indid < 255)
   drop index SENSOR.FK_SNT_SN_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('SENSOR')
            and   name  = 'FK_SNS_SN_FK'
            and   indid > 0
            and   indid < 255)
   drop index SENSOR.FK_SNS_SN_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('SENSOR')
            and   name  = 'FK_SNM_SN_FK'
            and   indid > 0
            and   indid < 255)
   drop index SENSOR.FK_SNM_SN_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SENSOR')
            and   type = 'U')
   drop table SENSOR
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SENSORMODEL')
            and   type = 'U')
   drop table SENSORMODEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SENSORSERIE')
            and   type = 'U')
   drop table SENSORSERIE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SENSORTYPE')
            and   type = 'U')
   drop table SENSORTYPE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SPEFAIL')
            and   type = 'U')
   drop table SPEFAIL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SPEPULLCAU')
            and   type = 'U')
   drop table SPEPULLCAU
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SYSTYPE')
            and   type = 'U')
   drop table SYSTYPE
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('WELL')
            and   name  = 'FK_FL_WL_FK'
            and   indid > 0
            and   indid < 255)
   drop index WELL.FK_FL_WL_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('WELL')
            and   name  = 'FK_PZ_WL_FK'
            and   indid > 0
            and   indid < 255)
   drop index WELL.FK_PZ_WL_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('WELL')
            and   name  = 'FK_WT_WL_FK'
            and   indid > 0
            and   indid < 255)
   drop index WELL.FK_WT_WL_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('WELL')
            and   type = 'U')
   drop table WELL
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('WELLINFO')
            and   name  = 'FK_CI_WI_FK'
            and   indid > 0
            and   indid < 255)
   drop index WELLINFO.FK_CI_WI_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('WELLINFO')
            and   type = 'U')
   drop table WELLINFO
go

if exists (select 1
            from  sysobjects
           where  id = object_id('WELLSTAT')
            and   type = 'U')
   drop table WELLSTAT
go

if exists (select 1
            from  sysobjects
           where  id = object_id('WELLTYPE')
            and   type = 'U')
   drop table WELLTYPE
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('XFRMVSD')
            and   name  = 'FK_XT_XV_FK'
            and   indid > 0
            and   indid < 255)
   drop index XFRMVSD.FK_XT_XV_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('XFRMVSD')
            and   name  = 'FK_XM_XV_FK'
            and   indid > 0
            and   indid < 255)
   drop index XFRMVSD.FK_XM_XV_FK
go

if exists (select 1
            from  sysindexes
           where  id    = object_id('XFRMVSD')
            and   name  = 'FK_XP_XV_FK'
            and   indid > 0
            and   indid < 255)
   drop index XFRMVSD.FK_XP_XV_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('XFRMVSD')
            and   type = 'U')
   drop table XFRMVSD
go

if exists (select 1
            from  sysobjects
           where  id = object_id('XVMAN')
            and   type = 'U')
   drop table XVMAN
go

if exists (select 1
            from  sysobjects
           where  id = object_id('XVPULSES')
            and   type = 'U')
   drop table XVPULSES
go

if exists (select 1
            from  sysobjects
           where  id = object_id('XVTYPE')
            and   type = 'U')
   drop table XVTYPE
go

/*==============================================================*/
/* Table: AFFCOM                                                */
/*==============================================================*/
create table AFFCOM (
   AC_CODE              varchar(26)          not null,
   AC_NAME              varchar(100)         null,
   constraint PK_AFFCOM primary key nonclustered (AC_CODE)
)
go

/*==============================================================*/
/* Table: BLOCK                                                 */
/*==============================================================*/
create table BLOCK (
   BL_CODE              varchar(26)          not null,
   CU_CODE              varchar(26)          null,
   GL_CODE              varchar(26)          null,
   BL_NAME              varchar(100)         not null,
   constraint PK_BLOCK primary key nonclustered (BL_CODE)
)
go

/*==============================================================*/
/* Index: FK_GL_BL_FK                                           */
/*==============================================================*/
create index FK_GL_BL_FK on BLOCK (
GL_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_CU_BL_FK                                           */
/*==============================================================*/
create index FK_CU_BL_FK on BLOCK (
CU_CODE ASC
)
go

/*==============================================================*/
/* Table: CABLE                                                 */
/*==============================================================*/
create table CABLE (
   CB_CODE              varchar(26)          not null,
   CL_CODE              varchar(26)          null,
   CA_CODE              varchar(26)          null,
   CM_CODE              varchar(26)          null,
   CR_CODE              varchar(26)          null,
   CB_SERIAL            varchar(100)         null,
   CB_LEN               int                  null,
   constraint PK_CABLE primary key nonclustered (CB_CODE)
)
go

/*==============================================================*/
/* Index: FK_CM_CB_FK                                           */
/*==============================================================*/
create index FK_CM_CB_FK on CABLE (
CM_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_CA_CB_FK                                           */
/*==============================================================*/
create index FK_CA_CB_FK on CABLE (
CA_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_CL_CB_FK                                           */
/*==============================================================*/
create index FK_CL_CB_FK on CABLE (
CL_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_CR_CB_FK                                           */
/*==============================================================*/
create index FK_CR_CB_FK on CABLE (
CR_CODE ASC
)
go

/*==============================================================*/
/* Table: CABLEARMOR                                            */
/*==============================================================*/
create table CABLEARMOR (
   CR_CODE              varchar(26)          not null,
   CR_NAME              varchar(100)         null,
   constraint PK_CABLEARMOR primary key nonclustered (CR_CODE)
)
go

/*==============================================================*/
/* Table: CABLEAWG                                              */
/*==============================================================*/
create table CABLEAWG (
   CA_CODE              varchar(26)          not null,
   CA_DESC              varchar(500)         null,
   constraint PK_CABLEAWG primary key nonclustered (CA_CODE)
)
go

/*==============================================================*/
/* Table: CABLELEVEL                                            */
/*==============================================================*/
create table CABLELEVEL (
   CL_CODE              varchar(26)          not null,
   CL_NAME              varchar(100)         null,
   constraint PK_CABLELEVEL primary key nonclustered (CL_CODE)
)
go

/*==============================================================*/
/* Table: CABLEMODEL                                            */
/*==============================================================*/
create table CABLEMODEL (
   CM_CODE              varchar(26)          not null,
   CM_DESC              varchar(100)         null,
   constraint PK_CABLEMODEL primary key nonclustered (CM_CODE)
)
go

/*==============================================================*/
/* Table: CONCEN                                                */
/*==============================================================*/
create table CONCEN (
   CC_CODE              varchar(26)          not null,
   CC_VALUE             int                  null,
   constraint PK_CONCEN primary key nonclustered (CC_CODE)
)
go

/*==============================================================*/
/* Table: CONTINFO                                              */
/*==============================================================*/
create table CONTINFO (
   CI_CODE              varchar(26)          not null,
   ST_CODE              varchar(26)          null,
   MN_CODE              varchar(26)          null,
   CI_ESP_DAY           int                  not null,
   constraint PK_CONTINFO primary key nonclustered (CI_CODE)
)
go

/*==============================================================*/
/* Index: FK_ST_CI_FK                                           */
/*==============================================================*/
create index FK_ST_CI_FK on CONTINFO (
ST_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MN_CI_FK                                           */
/*==============================================================*/
create index FK_MN_CI_FK on CONTINFO (
MN_CODE ASC
)
go

/*==============================================================*/
/* Table: COUNTRY                                               */
/*==============================================================*/
create table COUNTRY (
   CN_CODE              varchar(26)          not null,
   GM_CODE              varchar(26)          null,
   CN_NAME              varchar(100)         not null,
   CN_COD_REF           varchar(3)           not null,
   constraint PK_COUNTRY primary key nonclustered (CN_CODE)
)
go

/*==============================================================*/
/* Index: FK_GM_CN_FK                                           */
/*==============================================================*/
create index FK_GM_CN_FK on COUNTRY (
GM_CODE ASC
)
go

/*==============================================================*/
/* Table: CURRESPSTAT                                           */
/*==============================================================*/
create table CURRESPSTAT (
   CE_COD               varchar(26)          not null,
   CE_DESC              varchar(500)         not null,
   constraint PK_CURRESPSTAT primary key nonclustered (CE_COD)
)
go

/*==============================================================*/
/* Table: CUSTOMER                                              */
/*==============================================================*/
create table CUSTOMER (
   CU_CODE              varchar(26)          not null,
   CU_NAME              varchar(100)         not null,
   constraint PK_CUSTOMER primary key nonclustered (CU_CODE)
)
go

/*==============================================================*/
/* Table: ELECTCONN                                             */
/*==============================================================*/
create table ELECTCONN (
   EC_CODE              varchar(26)          not null,
   EM_CODE              varchar(26)          null,
   EC_SERIAL            varchar(100)         null,
   EC_DESC              varchar(500)         null,
   constraint PK_ELECTCONN primary key nonclustered (EC_CODE)
)
go

/*==============================================================*/
/* Index: FK_EM_EC_FK                                           */
/*==============================================================*/
create index FK_EM_EC_FK on ELECTCONN (
EM_CODE ASC
)
go

/*==============================================================*/
/* Table: ELECTMAN                                              */
/*==============================================================*/
create table ELECTMAN (
   EM_CODE              varchar(26)          not null,
   EM_NAME              varchar(100)         null,
   constraint PK_ELECTMAN primary key nonclustered (EM_CODE)
)
go

/*==============================================================*/
/* Table: EQUIPMENT                                             */
/*==============================================================*/
create table EQUIPMENT (
   EQ_CODE              varchar(26)          not null,
   EQ_PUMP_UP           varchar(26)          null,
   EQ_PUMP_MI           varchar(26)          null,
   EQ_PUMP_LO           varchar(26)          null,
   EQ_PUMP_CO           varchar(26)          null,
   EQ_INTAKE_IN         varchar(26)          null,
   EQ_INTAKE_GA         varchar(26)          null,
   EQ_MOTOR_UP          varchar(26)          null,
   EQ_MOTOR_MI          varchar(26)          null,
   EQ_MOTOR_LO          varchar(26)          null,
   EQ_SEAL_UP           varchar(26)          null,
   EQ_SEAL_MI           varchar(26)          null,
   EQ_SEAL_LO           varchar(26)          null,
   EQ_SENSOR            varchar(26)          null,
   EQ_MLE               varchar(26)          null,
   EQ_CABLE_UP          varchar(26)          null,
   EQ_CABLE_MI          varchar(26)          null,
   EQ_CABLE_LO          varchar(26)          null,
   EQ_ELC_COM           varchar(26)          null,
   EQ_XV_SD             varchar(26)          null,
   EQ_XV_SH             varchar(26)          null,
   EQ_XV_VS             varchar(26)          null,
   EQ_XV_SU             varchar(26)          null,
   constraint PK_EQUIPMENT primary key nonclustered (EQ_CODE)
)
go

/*==============================================================*/
/* Table: FAILANA                                               */
/*==============================================================*/
create table FAILANA (
   FA_CODE              varchar(26)          not null,
   GC_CODE              varchar(26)          null,
   FS_CODE              varchar(26)          null,
   FC_CODE              varchar(26)          null,
   CC_CODE              varchar(26)          null,
   SF_CODE              varchar(26)          null,
   PC_CODE              varchar(26)          null,
   FA_FAR_DATE          datetime             null,
   constraint PK_FAILANA primary key nonclustered (FA_CODE)
)
go

/*==============================================================*/
/* Index: FK_FC_FA_FK                                           */
/*==============================================================*/
create index FK_FC_FA_FK on FAILANA (
FC_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_FS_FA_FK                                           */
/*==============================================================*/
create index FK_FS_FA_FK on FAILANA (
FS_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_SF_FA_FK                                           */
/*==============================================================*/
create index FK_SF_FA_FK on FAILANA (
SF_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_GC_FA_FK                                           */
/*==============================================================*/
create index FK_GC_FA_FK on FAILANA (
GC_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_CC_FA_FK                                           */
/*==============================================================*/
create index FK_CC_FA_FK on FAILANA (
CC_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_PC_FA_FK                                           */
/*==============================================================*/
create index FK_PC_FA_FK on FAILANA (
PC_CODE ASC
)
go

/*==============================================================*/
/* Table: FAILCOM                                               */
/*==============================================================*/
create table FAILCOM (
   FC_CODE              varchar(26)          not null,
   FC_NAME              varchar(100)         null,
   constraint PK_FAILCOM primary key nonclustered (FC_CODE)
)
go

/*==============================================================*/
/* Table: FAILSUB                                               */
/*==============================================================*/
create table FAILSUB (
   FS_CODE              varchar(26)          not null,
   FS_NAME              varchar(100)         null,
   constraint PK_FAILSUB primary key nonclustered (FS_CODE)
)
go

/*==============================================================*/
/* Table: FIELD                                                 */
/*==============================================================*/
create table FIELD (
   FL_CODE              varchar(26)          not null,
   BL_CODE              varchar(26)          null,
   FL_NAME              varchar(100)         not null,
   constraint PK_FIELD primary key nonclustered (FL_CODE)
)
go

/*==============================================================*/
/* Index: FK_BL_FL_FK                                           */
/*==============================================================*/
create index FK_BL_FL_FK on FIELD (
BL_CODE ASC
)
go

/*==============================================================*/
/* Table: GENCEN                                                */
/*==============================================================*/
create table GENCEN (
   GC_CODE              varchar(26)          not null,
   GC_VALUE             int                  null,
   constraint PK_GENCEN primary key nonclustered (GC_CODE)
)
go

/*==============================================================*/
/* Table: GENPULLCAU                                            */
/*==============================================================*/
create table GENPULLCAU (
   GP_CODE              varchar(26)          not null,
   GP_NAME              varchar(100)         null,
   constraint PK_GENPULLCAU primary key nonclustered (GP_CODE)
)
go

/*==============================================================*/
/* Table: GEOLOC                                                */
/*==============================================================*/
create table GEOLOC (
   GL_CODE              varchar(26)          not null,
   CN_CODE              varchar(26)          null,
   GL_NAME              varchar(100)         not null,
   GL_COD_REF           varchar(3)           not null,
   constraint PK_GEOLOC primary key nonclustered (GL_CODE)
)
go

/*==============================================================*/
/* Index: FK_CN_GL_FK                                           */
/*==============================================================*/
create index FK_CN_GL_FK on GEOLOC (
CN_CODE ASC
)
go

/*==============================================================*/
/* Table: GEOMAR                                                */
/*==============================================================*/
create table GEOMAR (
   GM_CODE              varchar(26)          not null,
   GM_NAME              varchar(100)         not null,
   constraint PK_GEOMAR primary key nonclustered (GM_CODE)
)
go

/*==============================================================*/
/* Table: INTGAS                                                */
/*==============================================================*/
create table INTGAS (
   IN_CODE              varchar(26)          not null,
   IO_CODE              varchar(26)          null,
   IT_CODE              varchar(26)          null,
   MT_CODE              varchar(26)          null,
   IN_SERIAL            varchar(100)         null,
   IN_DESC              varchar(500)         null,
   constraint PK_INTGAS primary key nonclustered (IN_CODE)
)
go

/*==============================================================*/
/* Index: FK_IT_IN_FK                                           */
/*==============================================================*/
create index FK_IT_IN_FK on INTGAS (
IT_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_IO_IN_FK                                           */
/*==============================================================*/
create index FK_IO_IN_FK on INTGAS (
IO_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MT_IN_FK                                           */
/*==============================================================*/
create index FK_MT_IN_FK on INTGAS (
MT_CODE ASC
)
go

/*==============================================================*/
/* Table: INTGASOP                                              */
/*==============================================================*/
create table INTGASOP (
   IO_CODE              varchar(26)          not null,
   IO_DESC              varchar(500)         null,
   constraint PK_INTGASOP primary key nonclustered (IO_CODE)
)
go

/*==============================================================*/
/* Table: INTGASSERIE                                           */
/*==============================================================*/
create table INTGASSERIE (
   IS_CODE              varchar(26)          not null,
   IS_NAME              varchar(100)         null,
   constraint PK_INTGASSERIE primary key nonclustered (IS_CODE)
)
go

/*==============================================================*/
/* Table: INTGASTYPE                                            */
/*==============================================================*/
create table INTGASTYPE (
   IT_CODE              varchar(26)          not null,
   IS_CODE              varchar(26)          null,
   IT_DESC              varchar(500)         null,
   constraint PK_INTGASTYPE primary key nonclustered (IT_CODE)
)
go

/*==============================================================*/
/* Index: FK_IS_IT_FK                                           */
/*==============================================================*/
create index FK_IS_IT_FK on INTGASTYPE (
IS_CODE ASC
)
go

/*==============================================================*/
/* Table: MANUFACT                                              */
/*==============================================================*/
create table MANUFACT (
   MN_CODE              varchar(26)          not null,
   MN_NAME              varchar(100)         not null,
   constraint PK_MANUFACT primary key nonclustered (MN_CODE)
)
go

/*==============================================================*/
/* Table: METAL                                                 */
/*==============================================================*/
create table METAL (
   MT_CODE              varchar(26)          not null,
   MT_NAME              varchar(100)         null,
   constraint PK_METAL primary key nonclustered (MT_CODE)
)
go

/*==============================================================*/
/* Table: MLE                                                   */
/*==============================================================*/
create table MLE (
   ML_CODE2             varchar(26)          not null,
   MLM_CODE             varchar(26)          null,
   MLE_CODE             varchar(26)          null,
   MLT_CODE             varchar(26)          null,
   MLA_CODE             varchar(26)          null,
   ML_SERIE             varchar(100)         null,
   constraint PK_MLE primary key nonclustered (ML_CODE2)
)
go

/*==============================================================*/
/* Index: FK_MLS_ML_FK                                          */
/*==============================================================*/
create index FK_MLS_ML_FK on MLE (
MLE_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MLM_ML_FK                                          */
/*==============================================================*/
create index FK_MLM_ML_FK on MLE (
MLM_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MLT_ML_FK                                          */
/*==============================================================*/
create index FK_MLT_ML_FK on MLE (
MLT_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MLA_ML_FK                                          */
/*==============================================================*/
create index FK_MLA_ML_FK on MLE (
MLA_CODE ASC
)
go

/*==============================================================*/
/* Table: MLEARMOR                                              */
/*==============================================================*/
create table MLEARMOR (
   MLA_CODE             varchar(26)          not null,
   MLA_NAME             varchar(100)         null,
   constraint PK_MLEARMOR primary key nonclustered (MLA_CODE)
)
go

/*==============================================================*/
/* Table: MLEMODEL                                              */
/*==============================================================*/
create table MLEMODEL (
   MLM_CODE             varchar(26)          not null,
   MLM_NAME             varchar(100)         null,
   constraint PK_MLEMODEL primary key nonclustered (MLM_CODE)
)
go

/*==============================================================*/
/* Table: MLESERIE                                              */
/*==============================================================*/
create table MLESERIE (
   MLE_CODE             varchar(26)          not null,
   MLE_NAME             varchar(100)         null,
   constraint PK_MLESERIE primary key nonclustered (MLE_CODE)
)
go

/*==============================================================*/
/* Table: MLETYPE                                               */
/*==============================================================*/
create table MLETYPE (
   MLT_CODE             varchar(26)          not null,
   MLT_NAME             varchar(100)         null,
   constraint PK_MLETYPE primary key nonclustered (MLT_CODE)
)
go

/*==============================================================*/
/* Table: MOTEORSERIE                                           */
/*==============================================================*/
create table MOTEORSERIE (
   MS_CODE              varchar(26)          not null,
   MS_DESC              varchar(500)         null,
   constraint PK_MOTEORSERIE primary key nonclustered (MS_CODE)
)
go

/*==============================================================*/
/* Table: MOTOR                                                 */
/*==============================================================*/
create table MOTOR (
   MO_CODE              varchar(26)          not null,
   ML_CODE              varchar(26)          null,
   MM_CODE              varchar(26)          null,
   MT_CODE              varchar(26)          null,
   MS_CODE              varchar(26)          null,
   MY_CODE              varchar(26)          null,
   MO_DESC              varchar(500)         null,
   MO_HP                decimal(13,2)        null,
   MO_VOLT              decimal(13,2)        null,
   MO_AMP               decimal(13,2)        null,
   constraint PK_MOTOR primary key nonclustered (MO_CODE)
)
go

/*==============================================================*/
/* Index: FK_MS_MO_FK                                           */
/*==============================================================*/
create index FK_MS_MO_FK on MOTOR (
MS_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MM_MO_FK                                           */
/*==============================================================*/
create index FK_MM_MO_FK on MOTOR (
MM_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MY_MO_FK                                           */
/*==============================================================*/
create index FK_MY_MO_FK on MOTOR (
MY_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_ML_MO_FK                                           */
/*==============================================================*/
create index FK_ML_MO_FK on MOTOR (
ML_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MT_MO_FK                                           */
/*==============================================================*/
create index FK_MT_MO_FK on MOTOR (
MT_CODE ASC
)
go

/*==============================================================*/
/* Table: MOTORLEVEL                                            */
/*==============================================================*/
create table MOTORLEVEL (
   ML_CODE              varchar(26)          not null,
   ML_NAME              varchar(100)         null,
   constraint PK_MOTORLEVEL primary key nonclustered (ML_CODE)
)
go

/*==============================================================*/
/* Table: MOTORMODEL                                            */
/*==============================================================*/
create table MOTORMODEL (
   MM_CODE              varchar(26)          not null,
   MM_DESC              varchar(500)         null,
   constraint PK_MOTORMODEL primary key nonclustered (MM_CODE)
)
go

/*==============================================================*/
/* Table: MOTORTYPE                                             */
/*==============================================================*/
create table MOTORTYPE (
   MY_CODE              varchar(26)          not null,
   MY_DESC              varchar(500)         null,
   constraint PK_MOTORTYPE primary key nonclustered (MY_CODE)
)
go

/*==============================================================*/
/* Table: OPERINFO                                              */
/*==============================================================*/
create table OPERINFO (
   OI_CODE              varchar(26)          not null,
   WI_CODE              varchar(26)          null,
   WS_CODE              varchar(26)          null,
   CE_COD               varchar(26)          null,
   OI_PIP               int                  not null,
   OI_GROSS_PROD        int                  not null,
   OI_BSW               int                  not null,
   OI_OPER_FREQ         int                  not null,
   OI_COMM              varchar(500)         not null,
   constraint PK_OPERINFO primary key nonclustered (OI_CODE)
)
go

/*==============================================================*/
/* Index: FK_WS_OI_FK                                           */
/*==============================================================*/
create index FK_WS_OI_FK on OPERINFO (
WS_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_CE_OI_FK                                           */
/*==============================================================*/
create index FK_CE_OI_FK on OPERINFO (
CE_COD ASC
)
go

/*==============================================================*/
/* Index: FK_WI_OI_FK                                           */
/*==============================================================*/
create index FK_WI_OI_FK on OPERINFO (
WI_CODE ASC
)
go

/*==============================================================*/
/* Table: PRODZONE                                              */
/*==============================================================*/
create table PRODZONE (
   PZ_CODE              varchar(26)          not null,
   PZ_NOMBRE            varchar(100)         not null,
   constraint PK_PRODZONE primary key nonclustered (PZ_CODE)
)
go

/*==============================================================*/
/* Table: PULLCAUSE                                             */
/*==============================================================*/
create table PULLCAUSE (
   PC_CODE              varchar(26)          not null,
   RL_CODE              varchar(26)          null,
   SP_CODE              varchar(26)          null,
   GP_CODE              varchar(26)          null,
   PR_CODE              varchar(26)          null,
   AC_CODE              varchar(26)          null,
   PC_CUS_REA           varchar(300)         null,
   PC_COMM              varchar(500)         null,
   constraint PK_PULLCAUSE primary key nonclustered (PC_CODE)
)
go

/*==============================================================*/
/* Index: FK_PR_PC_FK                                           */
/*==============================================================*/
create index FK_PR_PC_FK on PULLCAUSE (
PR_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_GP_PC_FK                                           */
/*==============================================================*/
create index FK_GP_PC_FK on PULLCAUSE (
GP_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_SP_PC_FK                                           */
/*==============================================================*/
create index FK_SP_PC_FK on PULLCAUSE (
SP_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_AC_PC_FK                                           */
/*==============================================================*/
create index FK_AC_PC_FK on PULLCAUSE (
AC_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_RL_PC_FK                                           */
/*==============================================================*/
create index FK_RL_PC_FK on PULLCAUSE (
RL_CODE ASC
)
go

/*==============================================================*/
/* Table: PULLREA                                               */
/*==============================================================*/
create table PULLREA (
   PR_CODE              varchar(26)          not null,
   PR_DESC              varchar(500)         null,
   constraint PK_PULLREA primary key nonclustered (PR_CODE)
)
go

/*==============================================================*/
/* Table: PUMP                                                  */
/*==============================================================*/
create table PUMP (
   PU_CODE              varchar(26)          not null,
   PS_CODE              varchar(26)          null,
   PM_CODE              varchar(26)          null,
   PL_CODE              varchar(26)          null,
   MT_CODE              varchar(26)          null,
   PU_SERIAL            varchar(100)         null,
   PU_STAGE             int                  null,
   constraint PK_PUMP primary key nonclustered (PU_CODE)
)
go

/*==============================================================*/
/* Index: FK_PM_PU_FK                                           */
/*==============================================================*/
create index FK_PM_PU_FK on PUMP (
PM_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_PS_PU_FK                                           */
/*==============================================================*/
create index FK_PS_PU_FK on PUMP (
PS_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_PL_PU_FK                                           */
/*==============================================================*/
create index FK_PL_PU_FK on PUMP (
PL_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MT_PU_FK                                           */
/*==============================================================*/
create index FK_MT_PU_FK on PUMP (
MT_CODE ASC
)
go

/*==============================================================*/
/* Table: PUMPLEVEL                                             */
/*==============================================================*/
create table PUMPLEVEL (
   PL_CODE              varchar(26)          not null,
   PL_NAME              varchar(100)         null,
   constraint PK_PUMPLEVEL primary key nonclustered (PL_CODE)
)
go

/*==============================================================*/
/* Table: PUMPMODEL                                             */
/*==============================================================*/
create table PUMPMODEL (
   PM_CODE              varchar(26)          not null,
   PT_CODE              varchar(26)          null,
   PM_NAME              varchar(100)         null,
   constraint PK_PUMPMODEL primary key nonclustered (PM_CODE)
)
go

/*==============================================================*/
/* Index: FK_PT_PM_FK                                           */
/*==============================================================*/
create index FK_PT_PM_FK on PUMPMODEL (
PT_CODE ASC
)
go

/*==============================================================*/
/* Table: PUMPSERIE                                             */
/*==============================================================*/
create table PUMPSERIE (
   PS_CODE              varchar(26)          not null,
   PS_DESC              varchar(500)         null,
   constraint PK_PUMPSERIE primary key nonclustered (PS_CODE)
)
go

/*==============================================================*/
/* Table: PUMPTYPE                                              */
/*==============================================================*/
create table PUMPTYPE (
   PT_CODE              varchar(26)          not null,
   PT_DESC              varchar(500)         null,
   constraint PK_PUMPTYPE primary key nonclustered (PT_CODE)
)
go

/*==============================================================*/
/* Table: RUNLIFEDAT                                            */
/*==============================================================*/
create table RUNLIFEDAT (
   RL_CODE              varchar(26)          not null,
   OI_CODE              varchar(26)          null,
   EQ_CODE              varchar(26)          null,
   RL_INST              datetime             not null,
   RL_START             datetime             not null,
   RL_STOP              datetime             not null,
   RL_PULL              datetime             not null,
   constraint PK_RUNLIFEDAT primary key nonclustered (RL_CODE)
)
go

/*==============================================================*/
/* Index: FK_OI_RL_FK                                           */
/*==============================================================*/
create index FK_OI_RL_FK on RUNLIFEDAT (
OI_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_EQ_RL_FK                                           */
/*==============================================================*/
create index FK_EQ_RL_FK on RUNLIFEDAT (
EQ_CODE ASC
)
go

/*==============================================================*/
/* Table: SEAL                                                  */
/*==============================================================*/
create table SEAL (
   SE_CODE              varchar(26)          not null,
   SL_CODE              varchar(26)          null,
   SM_CODE              varchar(26)          null,
   SH_CODE              varchar(26)          null,
   MT_CODE              varchar(26)          null,
   SS_CODE              varchar(26)          null,
   SE_SERIAL            varchar(100)         null,
   SE_DESC              varchar(500)         null,
   constraint PK_SEAL primary key nonclustered (SE_CODE)
)
go

/*==============================================================*/
/* Index: FK_SS_SE_FK                                           */
/*==============================================================*/
create index FK_SS_SE_FK on SEAL (
SS_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_SM_SE_FK                                           */
/*==============================================================*/
create index FK_SM_SE_FK on SEAL (
SM_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_SH_SE_FK                                           */
/*==============================================================*/
create index FK_SH_SE_FK on SEAL (
SH_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_SL_SE_FK                                           */
/*==============================================================*/
create index FK_SL_SE_FK on SEAL (
SL_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MT_SE_FK                                           */
/*==============================================================*/
create index FK_MT_SE_FK on SEAL (
MT_CODE ASC
)
go

/*==============================================================*/
/* Table: SEALLEVEL                                             */
/*==============================================================*/
create table SEALLEVEL (
   SL_CODE              varchar(26)          not null,
   SL_NAME              varchar(100)         null,
   constraint PK_SEALLEVEL primary key nonclustered (SL_CODE)
)
go

/*==============================================================*/
/* Table: SEALMODEL                                             */
/*==============================================================*/
create table SEALMODEL (
   SM_CODE              varchar(26)          not null,
   SM_NAME              varchar(100)         null,
   constraint PK_SEALMODEL primary key nonclustered (SM_CODE)
)
go

/*==============================================================*/
/* Table: SEALSERIE                                             */
/*==============================================================*/
create table SEALSERIE (
   SS_CODE              varchar(26)          not null,
   SS_DESC              varchar(500)         null,
   constraint PK_SEALSERIE primary key nonclustered (SS_CODE)
)
go

/*==============================================================*/
/* Table: SEALSHAFT                                             */
/*==============================================================*/
create table SEALSHAFT (
   SH_CODE              varchar(26)          not null,
   SH_NAME              varchar(100)         null,
   constraint PK_SEALSHAFT primary key nonclustered (SH_CODE)
)
go

/*==============================================================*/
/* Table: SENSOR                                                */
/*==============================================================*/
create table SENSOR (
   SN_CODE              varchar(26)          not null,
   SNS_CODE             varchar(26)          null,
   SNT_CODE             varchar(26)          null,
   MT_CODE              varchar(26)          null,
   SNM_CODE             varchar(26)          null,
   SN_SERIAL            varchar(100)         null,
   constraint PK_SENSOR primary key nonclustered (SN_CODE)
)
go

/*==============================================================*/
/* Index: FK_SNM_SN_FK                                          */
/*==============================================================*/
create index FK_SNM_SN_FK on SENSOR (
SNM_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_SNS_SN_FK                                          */
/*==============================================================*/
create index FK_SNS_SN_FK on SENSOR (
SNS_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_SNT_SN_FK                                          */
/*==============================================================*/
create index FK_SNT_SN_FK on SENSOR (
SNT_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_MT_SN_FK                                           */
/*==============================================================*/
create index FK_MT_SN_FK on SENSOR (
MT_CODE ASC
)
go

/*==============================================================*/
/* Table: SENSORMODEL                                           */
/*==============================================================*/
create table SENSORMODEL (
   SNM_CODE             varchar(26)          not null,
   SNM_NAME             varchar(100)         null,
   constraint PK_SENSORMODEL primary key nonclustered (SNM_CODE)
)
go

/*==============================================================*/
/* Table: SENSORSERIE                                           */
/*==============================================================*/
create table SENSORSERIE (
   SNS_CODE             varchar(26)          not null,
   SNS_NAME             varchar(100)         null,
   constraint PK_SENSORSERIE primary key nonclustered (SNS_CODE)
)
go

/*==============================================================*/
/* Table: SENSORTYPE                                            */
/*==============================================================*/
create table SENSORTYPE (
   SNT_CODE             varchar(26)          not null,
   SNT_NAME             varchar(100)         null,
   constraint PK_SENSORTYPE primary key nonclustered (SNT_CODE)
)
go

/*==============================================================*/
/* Table: SPEFAIL                                               */
/*==============================================================*/
create table SPEFAIL (
   SF_CODE              varchar(26)          not null,
   SF_DESC              varchar(500)         null,
   constraint PK_SPEFAIL primary key nonclustered (SF_CODE)
)
go

/*==============================================================*/
/* Table: SPEPULLCAU                                            */
/*==============================================================*/
create table SPEPULLCAU (
   SP_CODE              varchar(26)          not null,
   SP_DESC              varchar(500)         null,
   constraint PK_SPEPULLCAU primary key nonclustered (SP_CODE)
)
go

/*==============================================================*/
/* Table: SYSTYPE                                               */
/*==============================================================*/
create table SYSTYPE (
   ST_CODE              varchar(26)          not null,
   ST_DESC              varchar(500)         not null,
   constraint PK_SYSTYPE primary key nonclustered (ST_CODE)
)
go

/*==============================================================*/
/* Table: WELL                                                  */
/*==============================================================*/
create table WELL (
   WL_CODE              varchar(26)          not null,
   WT_CODE              varchar(26)          null,
   PZ_CODE              varchar(26)          null,
   FL_CODE              varchar(26)          null,
   WL_NAME              varchar(100)         not null,
   constraint PK_WELL primary key nonclustered (WL_CODE)
)
go

/*==============================================================*/
/* Index: FK_WT_WL_FK                                           */
/*==============================================================*/
create index FK_WT_WL_FK on WELL (
WT_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_PZ_WL_FK                                           */
/*==============================================================*/
create index FK_PZ_WL_FK on WELL (
PZ_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_FL_WL_FK                                           */
/*==============================================================*/
create index FK_FL_WL_FK on WELL (
FL_CODE ASC
)
go

/*==============================================================*/
/* Table: WELLINFO                                              */
/*==============================================================*/
create table WELLINFO (
   WI_CODE              varchar(26)          not null,
   CI_CODE              varchar(26)          null,
   WI_TOT_RUN           int                  not null,
   WI_CEN_RUN           int                  not null,
   WIN_MD_DEEP          int                  not null,
   WI_TVD_DEEP          int                  not null,
   WI_INST_COMM         varchar(500)         not null,
   WI_FIELD_SERV        varchar(500)         not null,
   constraint PK_WELLINFO primary key nonclustered (WI_CODE)
)
go

/*==============================================================*/
/* Index: FK_CI_WI_FK                                           */
/*==============================================================*/
create index FK_CI_WI_FK on WELLINFO (
CI_CODE ASC
)
go

/*==============================================================*/
/* Table: WELLSTAT                                              */
/*==============================================================*/
create table WELLSTAT (
   WS_CODE              varchar(26)          not null,
   WS_DESC              varchar(500)         not null,
   constraint PK_WELLSTAT primary key nonclustered (WS_CODE)
)
go

/*==============================================================*/
/* Table: WELLTYPE                                              */
/*==============================================================*/
create table WELLTYPE (
   WT_CODE              varchar(26)          not null,
   WT_DESC              varchar(100)         not null,
   constraint PK_WELLTYPE primary key nonclustered (WT_CODE)
)
go

/*==============================================================*/
/* Table: XFRMVSD                                               */
/*==============================================================*/
create table XFRMVSD (
   XV_CODE              varchar(26)          not null,
   XM_CODE              varchar(26)          null,
   XP_CODE              varchar(26)          null,
   XT_CODE              varchar(26)          null,
   XV_SERIAL            varchar(100)         null,
   XV_KVA               varchar(100)         null,
   XV_DESC              varchar(100)         null,
   constraint PK_XFRMVSD primary key nonclustered (XV_CODE)
)
go

/*==============================================================*/
/* Index: FK_XP_XV_FK                                           */
/*==============================================================*/
create index FK_XP_XV_FK on XFRMVSD (
XP_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_XM_XV_FK                                           */
/*==============================================================*/
create index FK_XM_XV_FK on XFRMVSD (
XM_CODE ASC
)
go

/*==============================================================*/
/* Index: FK_XT_XV_FK                                           */
/*==============================================================*/
create index FK_XT_XV_FK on XFRMVSD (
XT_CODE ASC
)
go

/*==============================================================*/
/* Table: XVMAN                                                 */
/*==============================================================*/
create table XVMAN (
   XM_CODE              varchar(26)          not null,
   XM_NAME              varchar(100)         null,
   constraint PK_XVMAN primary key nonclustered (XM_CODE)
)
go

/*==============================================================*/
/* Table: XVPULSES                                              */
/*==============================================================*/
create table XVPULSES (
   XP_CODE              varchar(26)          not null,
   XP_NAME              varchar(100)         null,
   constraint PK_XVPULSES primary key nonclustered (XP_CODE)
)
go

/*==============================================================*/
/* Table: XVTYPE                                                */
/*==============================================================*/
create table XVTYPE (
   XT_CODE              varchar(26)          not null,
   XT_NAME              varchar(100)         null,
   constraint PK_XVTYPE primary key nonclustered (XT_CODE)
)
go

alter table BLOCK
   add constraint FK_BLOCK_FK_CU_BL_CUSTOMER foreign key (CU_CODE)
      references CUSTOMER (CU_CODE)
go

alter table BLOCK
   add constraint FK_BLOCK_FK_GL_BL_GEOLOC foreign key (GL_CODE)
      references GEOLOC (GL_CODE)
go

alter table CABLE
   add constraint FK_CABLE_FK_CA_CB_CABLEAWG foreign key (CA_CODE)
      references CABLEAWG (CA_CODE)
go

alter table CABLE
   add constraint FK_CABLE_FK_CL_CB_CABLELEV foreign key (CL_CODE)
      references CABLELEVEL (CL_CODE)
go

alter table CABLE
   add constraint FK_CABLE_FK_CM_CB_CABLEMOD foreign key (CM_CODE)
      references CABLEMODEL (CM_CODE)
go

alter table CABLE
   add constraint FK_CABLE_FK_CR_CB_CABLEARM foreign key (CR_CODE)
      references CABLEARMOR (CR_CODE)
go

alter table CONTINFO
   add constraint FK_CONTINFO_FK_MN_CI_MANUFACT foreign key (MN_CODE)
      references MANUFACT (MN_CODE)
go

alter table CONTINFO
   add constraint FK_CONTINFO_FK_ST_CI_SYSTYPE foreign key (ST_CODE)
      references SYSTYPE (ST_CODE)
go

alter table COUNTRY
   add constraint FK_COUNTRY_FK_GM_CN_GEOMAR foreign key (GM_CODE)
      references GEOMAR (GM_CODE)
go

alter table ELECTCONN
   add constraint FK_ELECTCON_FK_EM_EC_ELECTMAN foreign key (EM_CODE)
      references ELECTMAN (EM_CODE)
go

alter table FAILANA
   add constraint FK_FAILANA_FK_CC_FA_CONCEN foreign key (CC_CODE)
      references CONCEN (CC_CODE)
go

alter table FAILANA
   add constraint FK_FAILANA_FK_FC_FA_FAILCOM foreign key (FC_CODE)
      references FAILCOM (FC_CODE)
go

alter table FAILANA
   add constraint FK_FAILANA_FK_FS_FA_FAILSUB foreign key (FS_CODE)
      references FAILSUB (FS_CODE)
go

alter table FAILANA
   add constraint FK_FAILANA_FK_GC_FA_GENCEN foreign key (GC_CODE)
      references GENCEN (GC_CODE)
go

alter table FAILANA
   add constraint FK_FAILANA_FK_PC_FA_PULLCAUS foreign key (PC_CODE)
      references PULLCAUSE (PC_CODE)
go

alter table FAILANA
   add constraint FK_FAILANA_FK_SF_FA_SPEFAIL foreign key (SF_CODE)
      references SPEFAIL (SF_CODE)
go

alter table FIELD
   add constraint FK_FIELD_FK_BL_FL_BLOCK foreign key (BL_CODE)
      references BLOCK (BL_CODE)
go

alter table GEOLOC
   add constraint FK_GEOLOC_FK_CN_GL_COUNTRY foreign key (CN_CODE)
      references COUNTRY (CN_CODE)
go

alter table INTGAS
   add constraint FK_INTGAS_FK_IO_IN_INTGASOP foreign key (IO_CODE)
      references INTGASOP (IO_CODE)
go

alter table INTGAS
   add constraint FK_INTGAS_FK_IT_IN_INTGASTY foreign key (IT_CODE)
      references INTGASTYPE (IT_CODE)
go

alter table INTGAS
   add constraint FK_INTGAS_FK_MT_IN_METAL foreign key (MT_CODE)
      references METAL (MT_CODE)
go

alter table INTGASTYPE
   add constraint FK_INTGASTY_FK_IS_IT_INTGASSE foreign key (IS_CODE)
      references INTGASSERIE (IS_CODE)
go

alter table MLE
   add constraint FK_MLE_FK_MLA_ML_MLEARMOR foreign key (MLA_CODE)
      references MLEARMOR (MLA_CODE)
go

alter table MLE
   add constraint FK_MLE_FK_MLM_ML_MLEMODEL foreign key (MLM_CODE)
      references MLEMODEL (MLM_CODE)
go

alter table MLE
   add constraint FK_MLE_FK_MLS_ML_MLESERIE foreign key (MLE_CODE)
      references MLESERIE (MLE_CODE)
go

alter table MLE
   add constraint FK_MLE_FK_MLT_ML_MLETYPE foreign key (MLT_CODE)
      references MLETYPE (MLT_CODE)
go

alter table MOTOR
   add constraint FK_MOTOR_FK_ML_MO_MOTORLEV foreign key (ML_CODE)
      references MOTORLEVEL (ML_CODE)
go

alter table MOTOR
   add constraint FK_MOTOR_FK_MM_MO_MOTORMOD foreign key (MM_CODE)
      references MOTORMODEL (MM_CODE)
go

alter table MOTOR
   add constraint FK_MOTOR_FK_MS_MO_MOTEORSE foreign key (MS_CODE)
      references MOTEORSERIE (MS_CODE)
go

alter table MOTOR
   add constraint FK_MOTOR_FK_MT_MO_METAL foreign key (MT_CODE)
      references METAL (MT_CODE)
go

alter table MOTOR
   add constraint FK_MOTOR_FK_MY_MO_MOTORTYP foreign key (MY_CODE)
      references MOTORTYPE (MY_CODE)
go

alter table OPERINFO
   add constraint FK_OPERINFO_FK_CE_OI_CURRESPS foreign key (CE_COD)
      references CURRESPSTAT (CE_COD)
go

alter table OPERINFO
   add constraint FK_OPERINFO_FK_WI_OI_WELLINFO foreign key (WI_CODE)
      references WELLINFO (WI_CODE)
go

alter table OPERINFO
   add constraint FK_OPERINFO_FK_WS_OI_WELLSTAT foreign key (WS_CODE)
      references WELLSTAT (WS_CODE)
go

alter table PULLCAUSE
   add constraint FK_PULLCAUS_FK_AC_PC_AFFCOM foreign key (AC_CODE)
      references AFFCOM (AC_CODE)
go

alter table PULLCAUSE
   add constraint FK_PULLCAUS_FK_GP_PC_GENPULLC foreign key (GP_CODE)
      references GENPULLCAU (GP_CODE)
go

alter table PULLCAUSE
   add constraint FK_PULLCAUS_FK_PR_PC_PULLREA foreign key (PR_CODE)
      references PULLREA (PR_CODE)
go

alter table PULLCAUSE
   add constraint FK_PULLCAUS_FK_RL_PC_RUNLIFED foreign key (RL_CODE)
      references RUNLIFEDAT (RL_CODE)
go

alter table PULLCAUSE
   add constraint FK_PULLCAUS_FK_SP_PC_SPEPULLC foreign key (SP_CODE)
      references SPEPULLCAU (SP_CODE)
go

alter table PUMP
   add constraint FK_PUMP_FK_MT_PU_METAL foreign key (MT_CODE)
      references METAL (MT_CODE)
go

alter table PUMP
   add constraint FK_PUMP_FK_PL_PU_PUMPLEVE foreign key (PL_CODE)
      references PUMPLEVEL (PL_CODE)
go

alter table PUMP
   add constraint FK_PUMP_FK_PM_PU_PUMPMODE foreign key (PM_CODE)
      references PUMPMODEL (PM_CODE)
go

alter table PUMP
   add constraint FK_PUMP_FK_PS_PU_PUMPSERI foreign key (PS_CODE)
      references PUMPSERIE (PS_CODE)
go

alter table PUMPMODEL
   add constraint FK_PUMPMODE_FK_PT_PM_PUMPTYPE foreign key (PT_CODE)
      references PUMPTYPE (PT_CODE)
go

alter table RUNLIFEDAT
   add constraint FK_RUNLIFED_FK_EQ_RL_EQUIPMEN foreign key (EQ_CODE)
      references EQUIPMENT (EQ_CODE)
go

alter table RUNLIFEDAT
   add constraint FK_RUNLIFED_FK_OI_RL_OPERINFO foreign key (OI_CODE)
      references OPERINFO (OI_CODE)
go

alter table SEAL
   add constraint FK_SEAL_FK_MT_SE_METAL foreign key (MT_CODE)
      references METAL (MT_CODE)
go

alter table SEAL
   add constraint FK_SEAL_FK_SH_SE_SEALSHAF foreign key (SH_CODE)
      references SEALSHAFT (SH_CODE)
go

alter table SEAL
   add constraint FK_SEAL_FK_SL_SE_SEALLEVE foreign key (SL_CODE)
      references SEALLEVEL (SL_CODE)
go

alter table SEAL
   add constraint FK_SEAL_FK_SM_SE_SEALMODE foreign key (SM_CODE)
      references SEALMODEL (SM_CODE)
go

alter table SEAL
   add constraint FK_SEAL_FK_SS_SE_SEALSERI foreign key (SS_CODE)
      references SEALSERIE (SS_CODE)
go

alter table SENSOR
   add constraint FK_SENSOR_FK_MT_SN_METAL foreign key (MT_CODE)
      references METAL (MT_CODE)
go

alter table SENSOR
   add constraint FK_SENSOR_FK_SNM_SN_SENSORMO foreign key (SNM_CODE)
      references SENSORMODEL (SNM_CODE)
go

alter table SENSOR
   add constraint FK_SENSOR_FK_SNS_SN_SENSORSE foreign key (SNS_CODE)
      references SENSORSERIE (SNS_CODE)
go

alter table SENSOR
   add constraint FK_SENSOR_FK_SNT_SN_SENSORTY foreign key (SNT_CODE)
      references SENSORTYPE (SNT_CODE)
go

alter table WELL
   add constraint FK_WELL_FK_FL_WL_FIELD foreign key (FL_CODE)
      references FIELD (FL_CODE)
go

alter table WELL
   add constraint FK_WELL_FK_PZ_WL_PRODZONE foreign key (PZ_CODE)
      references PRODZONE (PZ_CODE)
go

alter table WELL
   add constraint FK_WELL_FK_WT_WL_WELLTYPE foreign key (WT_CODE)
      references WELLTYPE (WT_CODE)
go

alter table WELLINFO
   add constraint FK_WELLINFO_FK_CI_WI_CONTINFO foreign key (CI_CODE)
      references CONTINFO (CI_CODE)
go

alter table XFRMVSD
   add constraint FK_XFRMVSD_FK_XM_XV_XVMAN foreign key (XM_CODE)
      references XVMAN (XM_CODE)
go

alter table XFRMVSD
   add constraint FK_XFRMVSD_FK_XP_XV_XVPULSES foreign key (XP_CODE)
      references XVPULSES (XP_CODE)
go

alter table XFRMVSD
   add constraint FK_XFRMVSD_FK_XT_XV_XVTYPE foreign key (XT_CODE)
      references XVTYPE (XT_CODE)
go

